package com.example.shilehui;

import java.util.ArrayList;

import cn.jhc.Adapter.PublicUserEndowAdapter;
import cn.jhc.Adapter.PublicUserImpressionListViewAdpter;
import cn.jhc.bean.PublicUserEndow;
import cn.jhc.bean.PublicUserImpression;
import cn.jhc.service.PublicUserService;
import cn.jhc.utils.URL;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.Window;
import android.widget.ListView;

public class PublicUserImpressionActivity extends Activity {

	PublicUserService publicUserService;
	ArrayList<PublicUserImpression> publicUserImpressions;
	String first_url;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.public_user_impression);	
		Intent intent=getIntent();
	    String id=intent.getStringExtra("id");
	    first_url=URL.getPublicUserImpressionURL(id);
	    publicUserService=new PublicUserService();
	    
	    Runnable downloadRun = new Runnable() { 
			 
			@Override
			public void run() {  
				ArrayList<PublicUserImpression> publicUserImpressions=publicUserService.jsonResultAnalytical_GetPublicUserImpression(first_url);
				handler.sendMessage(handler.obtainMessage(10, publicUserImpressions));
			}
		};
		new Thread(downloadRun).start();
	}
	
	Handler handler =new Handler(){
		@Override
		public void handleMessage(Message msg) {
			ArrayList<PublicUserImpression> publicUserImpressions=(ArrayList<PublicUserImpression>) msg.obj;
			 ListView publicUserImpressionListView=(ListView) findViewById(R.id.public_user_impresssion_listview);
			 PublicUserImpressionListViewAdpter publicUserImpressionListViewAdpter=new PublicUserImpressionListViewAdpter(PublicUserImpressionActivity.this,publicUserImpressions);
			 publicUserImpressionListView.setAdapter(publicUserImpressionListViewAdpter);
		}
	};
	public void public_user_impression_back(View v){
		this.finish();
	}

}
